/*   1:    */ package com.atomikos.util;
/*   2:    */ 
/*   3:    */ import java.lang.reflect.InvocationHandler;
/*   4:    */ import java.lang.reflect.Proxy;
/*   5:    */ import java.net.URL;
/*   6:    */ import java.util.List;
/*   7:    */ 
/*   8:    */ public class ClassLoadingHelper
/*   9:    */ {
/*  10:    */   public static Object newProxyInstance(List classLoadersToTry, Class[] interfaces, InvocationHandler delegate)
/*  11:    */     throws IllegalArgumentException
/*  12:    */   {
/*  13: 63 */     Object ret = null;
/*  14: 64 */     ClassLoader cl = (ClassLoader)classLoadersToTry.get(0);
/*  15: 65 */     List remainingClassLoaders = classLoadersToTry.subList(1, classLoadersToTry.size());
/*  16:    */     try
/*  17:    */     {
/*  18: 68 */       return Proxy.newProxyInstance(cl, interfaces, delegate);
/*  19:    */     }
/*  20:    */     catch (IllegalArgumentException someClassNotFound)
/*  21:    */     {
/*  22: 70 */       if (remainingClassLoaders.size() > 0) {
/*  23: 72 */         ret = newProxyInstance(remainingClassLoaders, interfaces, delegate);
/*  24:    */       } else {
/*  25: 75 */         throw someClassNotFound;
/*  26:    */       }
/*  27:    */     }
/*  28: 79 */     return ret;
/*  29:    */   }
/*  30:    */   
/*  31:    */   public static Class loadClass(String className)
/*  32:    */     throws ClassNotFoundException
/*  33:    */   {
/*  34: 91 */     Class clazz = null;
/*  35:    */     try
/*  36:    */     {
/*  37: 93 */       clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
/*  38:    */     }
/*  39:    */     catch (ClassNotFoundException nf)
/*  40:    */     {
/*  41: 95 */       clazz = Class.forName(className);
/*  42:    */     }
/*  43: 97 */     return clazz;
/*  44:    */   }
/*  45:    */   
/*  46:    */   public static URL loadResourceFromClasspath(Class clazz, String resourceName)
/*  47:    */   {
/*  48:109 */     URL ret = null;
/*  49:    */     
/*  50:111 */     ret = clazz.getResource(resourceName);
/*  51:112 */     if (ret == null) {
/*  52:114 */       ret = clazz.getResource("/" + resourceName);
/*  53:    */     }
/*  54:116 */     return ret;
/*  55:    */   }
/*  56:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\atomikos-util\3.7.0\atomikos-util-3.7.0.jar
 * Qualified Name:     com.atomikos.util.ClassLoadingHelper
 * JD-Core Version:    0.7.0.1
 */